package com.xiaotu.spider.license.pipeline;

import com.xiaotu.common.model.MovieIssueMode;
import com.xiaotu.common.model.MovieLicenseMode;
import com.xiaotu.common.util.Constants;
import com.xiaotu.common.util.DataRedisKeyUtils;
import com.xiaotu.spider.APipeline;
import org.springframework.stereotype.Component;
import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;

import java.util.List;


/**
 * 电影发行经营许可证公示
 */
@Component("MovieIssuePipeline")
public class MovieIssuePipeline extends APipeline {
    @Override
    protected void doProcess(ResultItems resultItems, Task task) {
        List<MovieIssueMode> list = (List< MovieIssueMode>) resultItems.get(MovieIssueMode.class.getName());
        String key = DataRedisKeyUtils.getKey(Constants.DataRedisKey.Movie_Issue_YYYYMMDD);
        list.forEach(m -> {
            cacheHandler.hSet(key, m.getId(), m);
        });
    }

}
